/**
 * 
 */
package com.massyframework.beanskin.launcher.scanning.maven;

import java.io.File;

import org.w3c.dom.Document;

/**
 * {@link DefaultDevelopingMavenProjectResolver},实现的maven项目的解析
 * @author huangkh
 *
 */
public class DefaultDevelopingMavenProjectResolver 
	extends PomXmlParser
	implements DevelopingMavenProjectResolver {

	/**
	 * 构造方法
	 */
	public DefaultDevelopingMavenProjectResolver(AbstractMavenProjectRepository mavenProjectRepository) {
		super(mavenProjectRepository);
	}

	@Override
	public DevelopingMavenProject parse(File pomFile) throws Exception {
		Document doc = null;
		try {
			doc = this.loadDocument(pomFile);
		}catch(Throwable e) {
			throw new RuntimeException("load xml failed: " + pomFile.getAbsolutePath() + ".", e);
		}	
		
		ParentCoordinate parent = this.parseParentCoordinate(doc);
		DevelopingMavenProject.Builder builder = this.parseMavenProject(doc, parent);
		builder.baseDir(pomFile.getParentFile());
		return builder.build();
	}

}
